﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ChessOnline
{
    public enum CellColor
    {
        White = 0,
        Black = 1,
        None = 2
    };
    public enum ChessColor
    {
        White = 0,
        Black = 1,
        None = 2
    };
    public class GameCell
    {
        private Coordinate coord = new Coordinate();

        public Coordinate Coord
        {
            get { return coord; }
            set { coord = value; }
        }

        private CellColor color = CellColor.White;

        public CellColor Color
        {
            get { return color; }
            set { color = value; }
        }

        private ChessType figureType = ChessType.None;

        public ChessType FigureType
        {
            get { return figureType; }
            set { figureType = value; }
        }

        public ChessColor findOutChessColor()
        {
            //Проверить?
            ChessColor cc = ChessColor.White;
            if (this.figureType == ChessType.WhiteBishop ||
                this.figureType == ChessType.WhiteKing ||
                this.figureType == ChessType.WhitePawn ||
                this.figureType == ChessType.WhiteQueen ||
                this.figureType == ChessType.WhiteRook)
            {
                cc = ChessColor.White;
            }
            else if (this.figureType == ChessType.BlackBishop ||
                    this.figureType == ChessType.BlackKing ||
                    this.figureType == ChessType.BlackKnight ||
                    this.figureType == ChessType.BlackPawn ||
                    this.figureType == ChessType.BlackQueen ||
                    this.figureType == ChessType.BlackRook)
            {
                cc = ChessColor.Black;
            }
            return cc;
        }

        public GameCell()
        {
        }

        public static ChessColor CheckFigureColor(GameCell cell)
        {
            string figureName = cell.FigureType.ToString();
            if (figureName.Contains("White"))
                return ChessColor.White;
            if (figureName.Contains("Black"))
                return ChessColor.Black;
            return ChessColor.None;
        }
    }
}
